Uec3.TaskListWindow = Ext.extend(Ext.app.Module, {
			gridStore : null,
			detailWindow : null,
			handleTaskParameter : {
				"addOutSaleOrderWindowCreator" : function(task) {
					return {
						"id" : task["tableId"]
					};
				}
			},
			handleTaskParameterDefault : function(task) {
				return {
					"id" : task["tableId"]
				};
			},
			handleTask : function(rowIndex) {
				if (this.gridStore == null || this.app.workflowModules == null) {
					return;
				}
				var record = this.gridStore.getAt(rowIndex);
				var workflowSign = record.data["owner.taskNameEn"];
				if (!workflowSign) {
					return
				}
				var moduleId = this.app.workflowModules[workflowSign];
				if (!moduleId) {
					Ext.MessageBox.alert('提示', '没有查询到单据关联的模块!');
					return;
				}

				var parameter = this.handleTaskParameter[moduleId];
				parameter = (parameter ? parameter : this.handleTaskParameterDefault);

				var desktop = this.app.getDesktop();
				desktop.launchWindowByParam(moduleId, parameter.call(this, record.data));
			},

			detailTask : function(rowIndex) {

				if (this.gridStore == null) {
					return;
				}
				var record = this.gridStore.getAt(rowIndex);
				var desktop = this.app.getDesktop();
				this.detailWindow.createWindow(record, this.app);
			},

			createElements : function() {
				this.gridStore = new Ext.data.Store({
							proxy : new Ext.data.HttpProxy({
										url : Uec3.App.Constants.homeUrl + '/task/paging.do'
									}),
							baseParams : {
								start : 0,
								limit : 20
							},
							remoteSort : true,
							reader : new Ext.data.JsonReader({
										totalProperty : 'total',
										root : 'items'
									}, [{
												name : 'id'
											}, {
												name : 'workFlowId'
											}, {
												name : 'tableName'
											}, {
												name : 'tableId'
											}, {
												name : 'gmtStart'
											}, {
												name : 'gmtModify'/*,
												type : 'date',
												dateFormat : 'Y-m-d'*/
											}, {
												name : 'gmtEnd'/*,
												type : 'date',
												dateFormat : 'Y-m-d'*/
											}, {
												name : 'createCompanyId'
											}, {
												name : 'createCompanyName'
											}, {
												name : 'creatorId'
											}, {
												name : 'creatorName'
											}, {
												name : 'statusId'
											}, {
												name : 'status'
											}, {
												name : 'statusName'
											}, {
												name : 'finished'
											}, {
												name : 'revoked'
											}, {
												name : 'currentCompanyId'
											}, {
												name : 'currentCompanyName'
											}, {
												name : 'currentorId'
											}, {
												name : 'currentorName'
											}, {
												name : 'owner.ownerId'
											}, {
												name : 'owner.taskName'
											}, {
												name : 'owner.taskNameEn'
											}, {
												name : 'owner.tableCode'
											}, {
												name : 'owner.remark'
											}])
						});

				var gridColumnAction = {
					header : "操作",
					width : 120,
					sortable : false,
					dataIndex : 'id',
					renderer : this.moduleActionRenderer([{
								func : "handleTask",
								desc : "处理单据",
								reader : function(value, cellmeta, record, rowIndex, columnIndex, store) {
									return rowIndex;
								}
							}, {
								func : "detailTask",
								desc : "查看历史",
								reader : function(value, cellmeta, record, rowIndex, columnIndex, store) {
									return rowIndex;
								}
							}])
				};

				var gridColumnModel = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), gridColumnAction, {
							header : '任务名称',
							width : 100,
							sortable : false,
							dataIndex : 'owner.taskName'
						}, {
							header : '单据号',
							width : 150,
							sortable : false,
							dataIndex : 'owner.tableCode'
						}, {
							header : '创建公司名称',
							width : 200,
							sortable : false,
							dataIndex : 'createCompanyName'
						}, {
							header : '创建者',
							width : 70,
							sortable : false,
							dataIndex : 'creatorName'
						}, {
							header : '状态值',
							width : 70,
							sortable : false,
							dataIndex : 'status'
						}, {
							header : '状态名称',
							width : 80,
							sortable : false,
							dataIndex : 'statusName'
						}, {
							header : '是否结束',
							width : 60,
							sortable : false,
							dataIndex : 'finished',
							renderer : Ext.util.Format.booleanRenderer
						}, {
							header : '是否作废',
							width : 60,
							sortable : false,
							dataIndex : 'revoked',
							renderer : Ext.util.Format.booleanRenderer
						}, {
							//renderer : Ext.util.Format.dateRenderer('Y-m-d'),
							header : '开始时间',
							width : 130,
							sortable : false,
							dataIndex : 'gmtStart'
						}, {
							//renderer : Ext.util.Format.dateRenderer('Y-m-d'),
							header : '最近编辑时间',
							width : 130,
							sortable : false,
							dataIndex : 'gmtModify'
						}, {
							//renderer : Ext.util.Format.dateRenderer('Y-m-d'),
							header : '结束时间',
							width : 130,
							sortable : false,
							dataIndex : 'gmtEnd'
						}, {
							header : '当前公司名称',
							width : 200,
							sortable : false,
							dataIndex : 'currentCompanyName'
						}, {
							header : '当前处理人',
							width : 80,
							sortable : false,
							dataIndex : 'currentorName'
						}, {
							header : '摘要',
							width : 160,
							sortable : false,
							dataIndex : 'owner.remark'
						}]);
				var gridPanel = new Ext.grid.GridPanel({
							enableHdMenu : false,
							stripeRows : true,
							autoScroll : true,
							width : 1010,
							height : 500,
							frame :false,
              columnLines :true,
              height:408,     
                 
							loadMask : {
								msg : '...加载数据中'
							},
							viewConfig : {
								// forceFit : true,
								autoScroll : true,
								columnsText : '显示的列',
								scrollOffset : 20,
								sortAscText : '升序',
								sortDescText : '降序'
							},
							/*
							 * tbar : new Ext.Toolbar(['-', { text : '删除数据',
							 * handler : function() { } }]),
							 */
							bbar : new Ext.PagingToolbar({
										pageSize : 20,
										store : this.gridStore,
										displayInfo : true,
										displayMsg : '第 {0} - {1} 条  共 {2} 条',
										emptyMsg : '没有记录'
									}),
							iconCls : 'acc-icon',
							// title : '任务列表',
							cm : gridColumnModel,
							store : this.gridStore
						});
				this.gridStore.load();
				return gridPanel;
			},

			init : function(initParams) {

				this.detailWindow = new Uec3.TaskDetailWindow();
				this.detailWindow.init();
			},

			createWindow : function() {
				var win = null;
				var desktop = this.app.getDesktop();
				win = desktop.getWindow('taskListWin');
				if (!win) {
					win = desktop.createWindow({
								id : 'taskListWin',
								title : '我的单据',
								iconCls : 'acc-icon',
								taskbuttonTooltip : '浏览我的单据',
								width: 1020,
		            height: 580,
		            minWidth:600,
		            minHeight:400,
								shim: false,
		            animCollapse: false,
		            constrainHeader: true,
		            maximizable: true,
		            maximized:false,
								items : this.createElements()/*,
								listeners : {
									'resize' : function(win, width, height) {
										var grid = win.items.get(0);
										var winMinWidth = 900;
										var winMinHeight = 440;
										if (width < winMinWidth || height < winMinHeight) {
											win.setWidth(winMinWidth);
											win.setHeight(winMinHeight);
											grid.setHeight(winMinHeight - 28);
										} else {
											grid.setHeight(height - 28);
										}
									}
								}*/
							});
				}
				//win.get(0).setHeight(win.getHeight() - 28);
				win.get(0).setWidth(win.getWidth()-10);
				win.get(0).setHeight(win.getHeight()-28);
		    win.show(); 
		    
		    win.on('resize',function(win,width,height){
		    	    win.get(0).setWidth(width-10);
		      	  win.get(0).setHeight(height-28);
		      });
			}
		});

Uec3.TaskDetailWindow = Ext.extend(Ext.app.Module, {

			createElements : function(task) {
				var gridStore = new Ext.data.Store({
							proxy : new Ext.data.HttpProxy({
										url : Uec3.App.Constants.homeUrl + "/task/detail.do"
									}),
							baseParams : {
								'taskId' : task.id
							},
							remoteSort : true,
							reader : new Ext.data.JsonReader({}, [{
												name : 'id'
											}, {
												name : 'taskId'
											}, {
												name : 'remark'
											}, {
												name : 'actionName'
											}, {
												name : 'actionCompanyName'
											}, {
												name : 'actorName'
											}, {
												name : 'initStatusName'
											}, {
												name : 'endStatusName'
											}, {
												name : 'gmtAction',
												type : 'date',
												dateFormat : 'Y-m-d'
											}])
						});
				var gridColumnModel = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
							header : '操作名称',
							width : 100,
							sortable : false,
							dataIndex : 'actionName'
						}, {
							header : '执行人',
							width : 70,
							sortable : false,
							dataIndex : 'actorName'
						}, {
							header : '执行公司名称',
							width : 200,
							sortable : false,
							dataIndex : 'actionCompanyName'
						}, {
							header : '开始状态名称',
							width : 90,
							sortable : false,
							dataIndex : 'initStatusName'
						}, {
							header : '结束状态名称',
							width : 90,
							sortable : false,
							dataIndex : 'endStatusName'
						}, {
							renderer : Ext.util.Format.dateRenderer('Y-m-d'),
							header : '执行时间',
							width : 120,
							sortable : false,
							dataIndex : 'gmtAction'
						}, {
							header : '备注',
							width : 400,
							sortable : false,
							dataIndex : 'remark'
						}]);
				var gridPanel = new Ext.grid.GridPanel({
							enableColumnMove : false,
							enableColumnMoveResize : false,
							enableHdMenu : false,
							stripeRows : true,
							autoScroll : true,
							height : 420,
							loadMask : {
								msg : '...加载数据中'
							},
							viewConfig : {
								forceFit : true,
								columnsText : '显示的列',
								scrollOffset : 20,
								sortAscText : '升序',
								sortDescText : '降序'
							},
							iconCls : 'acc-icon',
							// title : '操作历史记录',
							cm : gridColumnModel,
							store : gridStore
						});
				var titleCss = "width:10%;text-align:right;font-weight:bold;";
				var html = ["<table style='width:100%;'>", '<tr>', "<td style='" + titleCss + "'>任务名称: </td><td width='15%'>" + task.data["owner.taskName"] + "</td>",
						"<td style='" + titleCss + "'>单据号: </td><td width='15%'>" + task.data["owner.tableCode"] + "</td>",
						"<td style='" + titleCss + "'>状态名称: </td><td width='15%'>" + task.data["statusName"] + "</td>", "<td style='" + titleCss + "'>状态值: </td><td>" + task.data["status"] + "</td>",
						'</tr>', '<tr>', "<td style='" + titleCss + "'>是否结束: </td><td>" + Ext.util.Format.booleanRenderer(task.data["finished"]) + "</td>",
						"<td style='" + titleCss + "'>是否作废: </td><td>" + Ext.util.Format.booleanRenderer(task.data["revoked"]) + "</td>",
						"<td style='" + titleCss + "'>开始日期: </td><td>" + Ext.util.Format.date(task.data["gmtStart"], "Y-m-d") + "</td>",
						"<td style='" + titleCss + "'>结束日期: </td><td>" + Ext.util.Format.date(task.data["gmtEnd"], "Y-m-d") + "</td>", '</tr>', '<tr>',
						"<td style='" + titleCss + "'>当前公司名称: </td><td>" + task.data["currentCompanyName"] + "</td>",
						"<td style='" + titleCss + "'>最近编辑日期: </td><td>" + Ext.util.Format.date(task.data["gmtModify"], "Y-m-d") + "</td>",
						"<td style='" + titleCss + "'>创建公司名称: </td><td>" + task.data["createCompanyName"] + "</td>",
						"<td style='" + titleCss + "'>创建者: </td><td>" + task.data["creatorName"] + "</td>", '</tr>', '<tr>',
						"<td style='" + titleCss + "'>当前处理人: </td><td colspan='5'>" + task.data["currentorName"] + "</td>", '</tr>', '</table>'];
				gridStore.load();
				var outlinePanel = new Ext.Panel({
							frame : true,
							height : 100,
							layout : 'form',
							html : html.join('')
						});
				var all_panel = new Ext.Panel({
							// labelAlign : 'right',
							// frame : true,
							// height : 400,
							autoWidth : true,
							autoScroll : true,
							items : [outlinePanel, gridPanel]
						});

				return all_panel;
			},

			init : function(initParams) {
			},

			createWindow : function(task, app) {
				var win = null;
				var code = (task.id ? task.id : "");
				var desktop = app.getDesktop();
				if (!win) {
					win = desktop.createWindow({
								id : 'task-detail-' + code,
								title : '单据操作历史',
								iconCls : 'acc-icon',
								taskbuttonTooltip : '单据操作历史',
								width : 900,
								shim : false,
								animCollapse : false,
								constrainHeader : true,
								maximizable : true,
								maximized : false,
								listeners : {
									'resize' : function(win, width, height) {
										var grid = win.items.get(0);
										var winMinWidth = 900;
										var winMinHeight = 440;
										if (width < winMinWidth || height < winMinHeight) {
											win.setWidth(winMinWidth);
											win.setHeight(winMinHeight);
											grid.setHeight(winMinHeight - 28);
										} else {
											grid.setHeight(height - 28);
										}
									}
								},
								items : this.createElements(task)
							});
				}
				win.show();
			}
		});
